package cn.itcast.chapter04.request;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @Author: 朱新舜
 * @Date: 2020-06-02 12:59:44
 */
@WebServlet("/resultServlet")
public class ResultServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/html;charset=utf-8");
        //获取PrinterWriter对象用于输出信息
        PrintWriter out = resp.getWriter();
        //获取request请求对象中保存的数据
        String company = (String) req.getAttribute("company");
        if(company!=null){
            out.println("公司名称："+company+"<br>");
        }

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req, resp);
    }
}
